home *** CD-ROM | disk | FTP | other *** search
/ AGA Toolkit '97 / The AGA Toolkit '97.iso / text / misc / port / oldstuff / portsource.lha / Port121.S < prev    next >
Encoding:
Text File  |  1993-02-16  |  14.1 KB  |  1,074 lines

  1. testmode    =    1
  2.  
  3.     include    "src:shadowlord.i"
  4.  
  5. ; V1.01
  6. ; Added bigger understanding of PC box characters.
  7. ; Now also understands one-wide box chars, and thick corner changed to #,
  8. ; single corner to +.
  9.  
  10. ; V1.02
  11. ; Added bad mode error, and error on no space between mode and the rest.
  12.  
  13. ; V1.10
  14. ; Cut endspace.
  15. ; Text output.
  16.  
  17. ; V1.13
  18. ; Percentage & size change
  19. ; extra lf
  20. ; extra cr removal in topc mode
  21.  
  22. ; V1.16
  23. ; Faster translate routines  25% speedup in frompc
  24. ; 6 more in frompc
  25. ; New helptext.
  26.  
  27. ; V1.18  11-feb
  28. ; Upper and lower case modes.
  29.  
  30. ; V1.21  15-feb
  31. ; tabs to spaces
  32. ; 3 new pc box chars
  33. ; bug fixed that confused port if the end of the commandline had spaces.
  34.  
  35. * 15-Feb-93
  36. * 15 days of hard coding
  37.  
  38. ; during the program
  39. ; a0=source
  40. ; a1=dest
  41. ; a2=spacebuf
  42.  
  43. ; d0=current char
  44. ; d1=load counter
  45. ; d2=savebyte counter
  46.  
  47.  
  48.     if    testmode=1
  49.     lea    test_comline,a0
  50.     move.l    #test_len,d0
  51.     endc
  52.  
  53. progstart:
  54.     clr.b    -1(a0,d0.l)
  55.     move.l    a0,commandstart
  56.     move.w    d0,commandlen
  57.     add.l    d0,a0
  58.     subq.l    #1,a0
  59.     move.l    a0,commandend
  60.  
  61.     lea    dosname,a1
  62.     moveq    #0,d0
  63.     move.l    execbase,a6
  64.     jsr    openlibrary(a6)
  65.     move.l    d0,dosbase
  66.  
  67.     move.l    dosbase,a6
  68.     jsr    output(a6)
  69.     move.l    d0,outstruct
  70.  
  71.     if    testmode=1
  72.     bne    err_testmode
  73.     endc
  74.  
  75.     move.l    #text_cursoroff,d2
  76.     moveq    #5,d3
  77.     bsr    printtext
  78.  
  79.     move.l    commandstart,a0
  80.     tst.b    (a0)            ; if blank commandline, instructions
  81.     beq    helptext
  82.     cmp.b    #"?",(a0)
  83.     beq    helptext
  84.  
  85. parsestart:
  86.     cmp.b    #"-",(a0)
  87.     beq    checkoption
  88.  
  89. parse:
  90.     cmp.b    #" ",1(a0)        ; at least one space after option
  91.     bne    err_nocomlinespace
  92.     cmp.b    #"p",(a0)
  93.     beq    frompcmode
  94.     cmp.b    #"P",(a0)
  95.     beq    topcmode
  96.     cmp.b    #"s",(a0)
  97.     beq    fromsf7mode
  98.     cmp.b    #"S",(a0)
  99.     beq    tosf7mode
  100.     cmp.b    #"u",(a0)
  101.     beq    toupcasemode
  102.     cmp.b    #"l",(a0)
  103.     beq    tolowcasemode
  104.     bra    err_badmode
  105.  
  106. checkoption:
  107.     cmp.b    #"n",1(a0)
  108.     beq    opt_nocutspace
  109.     cmp.b    #"?",1(a0)
  110.     beq    credits
  111.     cmp.b    #"t",1(a0)
  112.     beq    opt_tabconv
  113.     bra    err_badcomline
  114.  
  115. opt_nocutspace:
  116.     clr.b    mode_cutspace
  117.     addq.l    #2,a0
  118.     cmp.b    #" ",(a0)
  119.     bne    err_badcomline
  120.     bsr    skipspace
  121.     cmp.l    #0,a0
  122.     beq    err_badcomline
  123.     bra    parsestart
  124.  
  125. opt_tabconv:
  126.     addq.l    #2,a0            ; can be optimized; drop second
  127.     move.b    (a0),d0            ; addq.l #n,a0
  128.     ext.w    d0
  129.     ext.l    d0
  130.     cmp.b    #" ",d0
  131.     beq    opt_tabconv2
  132.     sub.b    #"0",d0
  133.     cmp.b    #9,d0
  134.     bhi    err_badcomline
  135.     cmp.b    #1,d0
  136.     bcs    err_badcomline
  137.     move.b    d0,tabsize
  138.     addq.l    #1,a0
  139.     cmp.b    #" ",(a0)
  140.     bne    err_badcomline
  141.  
  142. opt_tabconv1:
  143.     bsr    skipspace
  144.     cmp.l    #0,a0
  145.     beq    err_badcomline
  146.     bra    parsestart
  147.  
  148. opt_tabconv2:
  149.     move.b    #8,tabsize
  150.     bra    opt_tabconv1
  151.  
  152. frompcmode:
  153.     move.b    #1,mode
  154.     bra    nameparse
  155.  
  156. fromsf7mode:
  157.     move.b    #2,mode
  158.     bra    nameparse
  159.  
  160. tosf7mode:
  161.     move.b    #-2,mode
  162.     bra    nameparse
  163.  
  164. topcmode:
  165.     move.b    #-1,mode
  166.     bra    nameparse
  167.  
  168. toupcasemode:
  169.     move.b    #3,mode
  170.     bra    nameparse
  171.     
  172. tolowcasemode:
  173.     move.b    #4,mode
  174.     bra    nameparse
  175.  
  176. nameparse:
  177.     addq.l    #1,a0
  178.     bsr    skipspace
  179.     cmp.l    #0,a0
  180.     beq    err_badcomline
  181.     move.l    a0,sourcenamestart
  182.     bsr    findend
  183.     cmp.l    #0,a0
  184.     beq    err_badcomline
  185.     move.l    a0,sourcenameend
  186.     addq.l    #1,a0
  187.     sub.l    sourcenamestart,a0
  188.     move.l    a0,sourcenamelen
  189.  
  190.     move.l    sourcenamestart,a0
  191.     move.l    #sourcename,a1
  192.     move.l    sourcenamelen,d0
  193.     subq.l    #1,d0
  194.     cmp.b    #'"',(a0)
  195.     beq    removequotes
  196.  
  197. copysourcename:
  198.     move.b    (a0)+,(a1)+
  199.     dbf    d0,copysourcename
  200.     clr.b    (a1)
  201.  
  202.     move.l    sourcenameend,a0
  203.     addq.l    #1,a0
  204.     cmp.l    commandend,a0
  205.     beq    nodest
  206.  
  207.     bsr    skipspace
  208.     cmp.l    #0,a0
  209.     beq    nodest
  210.     move.l    a0,destnamestart
  211.     bsr    findend
  212.     cmp.l    #0,a0
  213.     beq    err_badcomline
  214.     move.l    a0,destnameend
  215.     addq.l    #1,a0
  216.     sub.l    destnamestart,a0
  217.     move.l    a0,destnamelen
  218.     move.l    a0,d0
  219.  
  220.     move.l    destnamestart,a0
  221.     move.l    #destname,a1
  222.     subq.l    #1,d0
  223.     cmp.b    #'"',(a0)
  224.     beq    removequotes1
  225.  
  226. copydestname:
  227.     move.b    (a0)+,(a1)+
  228.     dbf    d0,copydestname
  229.     bra    openfiles
  230.  
  231. removequotes:
  232.     addq.l    #1,a0
  233.     subq.l    #2,d0
  234.     bra    copysourcename
  235.  
  236. removequotes1:
  237.     addq.l    #1,a0
  238.     subq.l    #2,d0
  239.     bra    copydestname
  240.  
  241. removequotes2:
  242.     addq.l    #1,a0
  243.     subq.l    #2,d0
  244.     bra    copydestname1
  245.  
  246. nodest:
  247.     move.l    #destname,a1
  248.     move.l    sourcenamestart,a0
  249.     move.l    sourcenamelen,d0
  250.     subq.l    #1,d0
  251.     cmp.b    #'"',(a0)
  252.     beq    removequotes2
  253.  
  254. copydestname1:
  255.     move.b    (a0)+,(a1)+
  256.     dbf    d0,copydestname1
  257.  
  258.     cmp.b    #-1,mode
  259.     beq    pcsuffix
  260.     cmp.b    #-2,mode
  261.     beq    sf7suffix
  262.  
  263. amigasuffix:
  264.     lea    text_amigasuf,a0
  265.     moveq    #4-1,d0
  266.  
  267. amigasuffix1:
  268.     move.b    (a0)+,(a1)+
  269.     dbf    d0,amigasuffix1
  270.     bra    openfiles
  271.  
  272. pcsuffix:
  273.     lea    text_pcsuf,a0
  274.     moveq    #3-1,d0
  275.  
  276. pcsuffix1:
  277.     move.b    (a0)+,(a1)+
  278.     dbf    d0,pcsuffix1
  279.     bra    openfiles
  280.  
  281. sf7suffix:
  282.     lea    text_sf7suf,a0
  283.     moveq    #4-1,d0
  284.  
  285. sf7suffix1:
  286.     move.b    (a0)+,(a1)+
  287.     dbf    d0,sf7suffix1
  288.  
  289. openfiles:
  290.     clr.b    (a1)            ; end of filename
  291.     move.l    #sourcename,d1
  292.     move.l    #1005,d2
  293.     move.l    dosbase,a6
  294.     jsr    open(a6)
  295.     tst.l    d0
  296.     beq    err_nosource
  297.     move.l    d0,sourcehandle
  298.  
  299.     move.l    #destname,d1
  300.     move.l    #1006,d2
  301.     move.l    dosbase,a6
  302.     jsr    open(a6)
  303.     tst.l    d0
  304.     beq    err_nodest
  305.     move.l    d0,desthandle
  306.  
  307. readblock:
  308.     move.l    sourcehandle,d1
  309.     move.l    #sourcebuf,d2
  310.     move.l    #1024,d3
  311.     move.l    dosbase,a6
  312.     jsr    read(a6)
  313.     add.l    d0,readbytes
  314.     move.l    d0,d1
  315.     beq    closefiles        ; readbytes=0 - quit
  316.     subq.l    #1,d1
  317.     moveq    #0,d2
  318.  
  319.     lea    sourcebuf,a0
  320.     lea    destbuf,a1
  321.  
  322. morecharacters:
  323.     move.b    (a0)+,d0
  324.     bra    cutspace
  325.  
  326. checknormal:
  327.     cmp.b    #-2,mode
  328.     beq    tosf7
  329.     cmp.b    #-1,mode
  330.     beq    topc
  331.     cmp.b    #2,mode
  332.     beq    fromsf7
  333.     cmp.b    #3,mode
  334.     beq    toupcase
  335.     cmp.b    #4,mode
  336.     beq    tolowcase
  337.  
  338. frompc:
  339.     cmp.b    #" ",d0
  340.     bcs    frompc1
  341.     cmp.b    #"~",d0
  342.     bhi    frompc1
  343.     bra    nextchar
  344.  
  345. frompc1:
  346.     cmp.b    #$84,d0
  347.     beq    ami_lowae
  348.     cmp.b    #$94,d0
  349.     beq    ami_lowoe
  350.     cmp.b    #$8e,d0
  351.     beq    ami_upae
  352.     cmp.b    #$99,d0
  353.     beq    ami_upoe
  354.     cmp.b    #13,d0
  355.     beq    nochar
  356.     cmp.b    #0,d0
  357.     beq    nochar
  358.     cmp.b    #$1a,d0            ; ctrl+z
  359.     beq    nochar
  360.     cmp.b    #$c9,d0
  361.     beq    ami_bigcorner
  362.     cmp.b    #$bb,d0
  363.     beq    ami_bigcorner
  364.     cmp.b    #$c8,d0
  365.     beq    ami_bigcorner
  366.     cmp.b    #$bc,d0
  367.     beq    ami_bigcorner
  368.     cmp.b    #$cd,d0
  369.     beq    ami_doubleline
  370.     cmp.b    #$ba,d0
  371.     beq    ami_upline
  372.     cmp.b    #$b3,d0
  373.     beq    ami_upline
  374.     cmp.b    #$b0,d0
  375.     beq    ami_box
  376.     cmp.b    #$b1,d0
  377.     beq    ami_box
  378.     cmp.b    #$b2,d0
  379.     beq    ami_box
  380.     cmp.b    #$c4,d0
  381.     beq    ami_singleline
  382.     cmp.b    #$c0,d0
  383.     beq    ami_smallcorner
  384.     cmp.b    #$d9,d0
  385.     beq    ami_smallcorner
  386.     cmp.b    #$bf,d0
  387.     beq    ami_smallcorner
  388.     cmp.b    #$da,d0
  389.     beq    ami_smallcorner
  390.     cmp.b    #$d4,d0
  391.     beq    ami_bigcorner
  392.     cmp.b    #$c3,d0
  393.     beq    ami_smallcorner
  394.     cmp.b    #$b7,d0
  395.     beq    ami_smallcorner
  396.     cmp.b    #$b6,d0
  397.     beq    ami_bigcorner
  398.     cmp.b    #$d3,d0
  399.     beq    ami_smallcorner
  400.     cmp.b    #$d6,d0
  401.     beq    ami_smallcorner
  402.     cmp.b    #$bd,d0
  403.     beq    ami_smallcorner
  404.     cmp.b    #20,d0
  405.     beq    ami_182
  406.     cmp.b    #128,d0
  407.     beq    ami_231
  408.  
  409. nextchar:
  410.     move.b    d0,(a1)+
  411.     addq.l    #1,d2
  412.     add.w    #1,col
  413.  
  414. nochar:
  415.     dbf    d1,morecharacters
  416.  
  417.     move.l    desthandle,d1
  418.     move.l    d2,d3
  419.     add.l    d2,writtenbytes
  420.     move.l    #destbuf,d2
  421.     move.l    dosbase,a6
  422.     jsr    write(a6)
  423.  
  424.     move.l    #text_input,d2
  425.     moveq    #15,d3
  426.     bsr    printtext
  427.  
  428.     lea    numberbuf,a0
  429.     move.l    readbytes,d0
  430.     bsr    num2ascii
  431.  
  432.     move.l    a0,d2
  433.     move.l    d0,d3
  434.     bsr    printtext
  435.  
  436.     move.l    #text_output,d2
  437.     moveq    #18,d3
  438.     bsr    printtext
  439.  
  440.     lea    numberbuf,a0
  441.     move.l    writtenbytes,d0
  442.     bsr    num2ascii
  443.  
  444.     move.l    a0,d2
  445.     move.l    d0,d3
  446.     bsr    printtext
  447.  
  448.     move.l    #text_cr,d2
  449.     moveq    #1,d3
  450.     bsr    printtext
  451.  
  452.     bra    readblock
  453.  
  454. cutspace:
  455.     move.l    spacepointer,a2
  456.     cmp.b    #" ",d0
  457.     beq    addspace
  458.     cmp.b    #9,d0            ; tab
  459.     beq    addtab
  460.  
  461.     cmp.b    #1,mode_cutspace
  462.     bne    cutspace2
  463.  
  464.     cmp.b    #10,d0            ; lf
  465.     beq    cutspaces
  466.     cmp.b    #13,d0            ; cr
  467.     beq    cutspaces
  468.  
  469. cutspace1:
  470.     tst.l    spacenumber
  471.     bne    linkspaces
  472.     bra    checknormal
  473.  
  474. cutspace2:
  475.     cmp.b    #10,d0
  476.     beq    clearcol
  477.     cmp.b    #13,d0
  478.     beq    clearcol
  479.     bra    cutspace1
  480.  
  481. clearcol:
  482.     move.w    #-1,col
  483.     bra    cutspace1
  484.  
  485. addspace:
  486.     addq.l    #1,spacenumber
  487.     move.b    d0,(a2)+
  488.     move.l    a2,spacepointer
  489.     add.w    #1,col
  490.     bra    nochar
  491.  
  492. addtab:
  493.     move.b    tabsize,d4
  494.     bne    tabconv
  495.     bra    addspace
  496.  
  497. tabconv:
  498.     ext.w    d4
  499.     ext.l    d4
  500.     move.w    col,d3
  501.     divu    d4,d3
  502.     swap    d3
  503.     sub.w    d3,d4
  504.     add.l    d4,spacenumber
  505.     add.w    d4,col
  506.     subq.w    #1,d4
  507.  
  508. tabconv1:
  509.     move.b    #" ",(a2)+
  510.     dbf    d4,tabconv1
  511.     move.l    a2,spacepointer
  512.     bra    nochar
  513.  
  514. cutspaces:
  515.     clr.l    spacenumber
  516.     move.l    #spacebuf,spacepointer
  517.     move.w    #-1,col            ; col will be zero when eol gets added
  518.     bra    checknormal
  519.  
  520. linkspaces:
  521.     move.l    spacenumber,d3
  522.     add.l    d3,d2
  523.     subq.l    #1,d3
  524.     lea    spacebuf,a2
  525.  
  526. linkspaces1:
  527.     move.b    (a2)+,(a1)+
  528.     dbf    d3,linkspaces1
  529.     clr.l    spacenumber
  530.     move.l    #spacebuf,spacepointer
  531.     bra    checknormal
  532.  
  533. topc:
  534.     cmp.b    #"ä",d0
  535.     beq    pc_lowae
  536.     cmp.b    #"ö",d0
  537.     beq    pc_lowoe
  538.     cmp.b    #"Ä",d0
  539.     beq    pc_upae
  540.     cmp.b    #"Ö",d0
  541.     beq    pc_upoe
  542.     cmp.b    #13,d0
  543.     beq    nochar
  544.     cmp.b    #10,d0
  545.     beq    addcr
  546.     cmp.b    #0,d0
  547.     beq    nochar
  548.     cmp.b    #$1a,d0            ; ctrl+z
  549.     beq    nochar
  550.     bra    nextchar
  551.  
  552. fromsf7:
  553.     cmp.b    #"{",d0
  554.     beq    ami_lowae
  555.     cmp.b    #"|",d0
  556.     beq    ami_lowoe
  557.     cmp.b    #"[",d0
  558.     beq    ami_upae
  559.     cmp.b    #"\",d0
  560.     beq    ami_upoe
  561.     cmp.b    #13,d0
  562.     beq    nochar
  563.     cmp.b    #0,d0
  564.     beq    nochar
  565.     cmp.b    #$1a,d0            ; ctrl+z
  566.     beq    nochar
  567.     bra    nextchar
  568.  
  569. tosf7:
  570.     cmp.b    #"ä",d0
  571.     beq    sf7_lowae
  572.     cmp.b    #"ö",d0
  573.     beq    sf7_lowoe
  574.     cmp.b    #"Ä",d0
  575.     beq    sf7_upae
  576.     cmp.b    #"Ö",d0
  577.     beq    sf7_upoe
  578.     cmp.b    #10,d0
  579.     beq    addcr
  580.     cmp.b    #0,d0
  581.     beq    nochar
  582.     cmp.b    #$1a,d0            ; ctrl+z
  583.     beq    nochar
  584.     bra    nextchar
  585.  
  586. toupcase:
  587.     cmp.b    #"ä",d0
  588.     beq    ami_upae
  589.     cmp.b    #"ö",d0
  590.     beq    ami_upoe
  591.     cmp.b    #"a",d0
  592.     bcs    nextchar
  593.     cmp.b    #"z",d0
  594.     bhi    nextchar
  595.  
  596.     eor.b    #%100000,d0
  597.     bra    nextchar
  598.  
  599. tolowcase:
  600.     cmp.b    #"Ä",d0
  601.     beq    ami_lowae
  602.     cmp.b    #"Ö",d0
  603.     beq    ami_lowoe
  604.     cmp.b    #"A",d0
  605.     bcs    nextchar
  606.     cmp.b    #"Z",d0
  607.     bhi    nextchar
  608.  
  609.     or.b    #%100000,d0
  610.     bra    nextchar
  611.  
  612. ami_182:
  613.     move.b    #182,d0
  614.     bra    nextchar
  615.  
  616. ami_231:
  617.     move.b    #231,d0
  618.     bra    nextchar
  619.  
  620. ami_singleline:
  621.     move.b    #"-",d0
  622.     bra    nextchar
  623.  
  624. ami_box:
  625.     move.b    #$7f,d0
  626.     bra    nextchar
  627.  
  628. ami_upline:
  629.     move.b    #"|",d0
  630.     bra    nextchar
  631.  
  632. ami_doubleline:
  633.     move.b    #"=",d0
  634.     bra    nextchar
  635.  
  636. ami_smallcorner:
  637.     move.b    #"+",d0
  638.     bra    nextchar
  639.  
  640. ami_bigcorner:
  641.     move.b    #"#",d0
  642.     bra    nextchar
  643.  
  644. ami_lowae:
  645.     move.b    #"ä",d0
  646.     bra    nextchar
  647.  
  648. ami_lowoe:
  649.     move.b    #"ö",d0
  650.     bra    nextchar
  651.  
  652. ami_upae:
  653.     move.b    #"Ä",d0
  654.     bra    nextchar
  655.  
  656. ami_upoe:
  657.     move.b    #"Ö",d0
  658.     bra    nextchar
  659.  
  660. pc_lowae:
  661.     move.b    #$84,d0
  662.     bra    nextchar
  663.  
  664. pc_lowoe:
  665.     move.b    #$94,d0
  666.     bra    nextchar
  667.  
  668. pc_upae:
  669.     move.b    #$8e,d0
  670.     bra    nextchar
  671.  
  672. pc_upoe:
  673.     move.b    #$99,d0
  674.     bra    nextchar
  675.  
  676. sf7_lowae:
  677.     move.b    #"{",d0
  678.     bra    nextchar
  679.  
  680. sf7_lowoe:
  681.     move.b    #"|",d0
  682.     bra    nextchar
  683.  
  684. sf7_upae:
  685.     move.b    #"[",d0
  686.     bra    nextchar
  687.  
  688. sf7_upoe:
  689.     move.b    #"\",d0
  690.     bra    nextchar
  691.  
  692. addcr:
  693.     move.b    #13,(a1)+
  694.     addq.l    #1,d2
  695.     bra    nextchar
  696.  
  697. closefiles:
  698.     move.l    sourcehandle,d1
  699.     move.l    dosbase,a6
  700.     jsr    close(a6)
  701.     move.l    desthandle,d1
  702.     move.l    dosbase,a6
  703.     jsr    close(a6)
  704.  
  705.     move.l    #text_final,d2
  706.     moveq    #26,d3
  707.     bsr    printtext
  708.  
  709.     move.l    readbytes,d1
  710.     move.l    writtenbytes,d0
  711.  
  712.     sub.l    d1,d0
  713.     bmi    closefiles1        ; negative
  714.  
  715.     move.l    d0,d7
  716.     beq    closefiles2        ; if zero, no sign
  717.  
  718.     move.l    #text_possign,d2
  719.     moveq    #1,d3
  720.     bsr    printtext
  721.     bra    closefiles2
  722.  
  723. closefiles1:
  724.     neg.l    d0
  725.     move.l    d0,d7
  726.  
  727.     move.l    #text_negsign,d2
  728.     moveq    #1,d3
  729.     bsr    printtext
  730.  
  731. closefiles2:
  732.     move.l    d7,d0
  733.     lea    numberbuf,a0
  734.     bsr    num2ascii
  735.  
  736.     move.l    a0,d2
  737.     move.l    d0,d3
  738.     bsr    printtext
  739.  
  740.     move.l    #text_doublespace,d2
  741.     moveq    #2,d3
  742.     bsr    printtext
  743.  
  744.     move.l    writtenbytes,d0
  745.     move.l    readbytes,d1
  746.     bsr    percentage
  747.  
  748.     lea    numberbuf,a0
  749.     bsr    num2ascii
  750.  
  751.     move.l    a0,d2
  752.     move.l    d0,d3
  753.     bsr    printtext
  754.  
  755.     move.l    #text_percentsign,d2
  756.     move.l    #11,d3
  757.     bsr    printtext
  758.  
  759.     move.l    #text_lf,d2
  760.     move.l    #1,d3
  761.     bsr    printtext
  762.     bra    endprogram1
  763.  
  764. helptext:
  765.     move.l    #text_helptext,d2
  766.     move.l    #len_helptext,d3
  767.     bsr    printtext
  768.     bra    endprogram1
  769.  
  770. credits:
  771.     move.l    #text_credits,d2
  772.     move.l    #len_credits,d3
  773.     bsr    printtext
  774.     bra    endprogram1
  775.  
  776.     if    testmode=1
  777. err_testmode:
  778.     move.l    #$ffff,d0
  779.  
  780. err_testmode1:
  781.     move.w    #$f00,$dff180
  782.     dbf    d0,err_testmode1
  783.     bra    endprogram1
  784.     endc
  785.  
  786. err_nosource:
  787.     move.l    #text_nosource,d2
  788.     moveq    #36,d3
  789.     bsr    printtext
  790.     bra    endprogram1
  791.  
  792. err_nomemory:
  793.     move.l    #text_nomemory,d2
  794.     moveq    #26,d3
  795.     bsr    printtext
  796.     bra    endprogram1
  797.  
  798. err_badcomline:
  799.     move.l    #text_badcomline,d2
  800.     moveq    #25,d3
  801.     bsr    printtext
  802.     bra    endprogram1
  803.  
  804. err_nodest:
  805.     move.l    #text_nodest,d2
  806.     moveq    #41,d3
  807.     bsr    printtext
  808.     bra    endprogram2
  809.  
  810. err_badmode:
  811.     move.l    #text_badmode,d2
  812.     moveq    #32,d3
  813.     bsr    printtext
  814.     bra    endprogram1
  815.  
  816. err_nocomlinespace:
  817.     move.l    #text_nocomlinespace,d2
  818.     moveq    #60,d3
  819.     bsr    printtext
  820.     bra    endprogram1
  821.  
  822. endprogram1:
  823.     move.l    #text_cursoron,d2
  824.     moveq    #5,d3
  825.     bsr    printtext
  826.  
  827.     move.l    execbase,a6
  828.     move.l    dosbase,a1
  829.     jsr    closelibrary(a6)
  830.     moveq    #0,d0
  831.     rts
  832.  
  833. endprogram2:
  834.     move.l    sourcehandle,d1
  835.     move.l    dosbase,a6
  836.     jsr    close(a6)
  837.     bra    endprogram1
  838.  
  839. **********
  840. ** SUBS **
  841. **********
  842.  
  843. printtext:
  844.     if    testmode=1
  845.     rts
  846.     endc
  847.     move.l    outstruct,d1
  848.     move.l    dosbase,a6
  849.     jsr    write(a6)
  850.     rts
  851.  
  852. skipspace:
  853.     cmp.b    #" ",(a0)
  854.     beq    skipspace1
  855.     rts
  856.  
  857. skipspace1:
  858.     add.l    #1,a0
  859.     cmp.l    commandend,a0
  860.     bcs    skipspace
  861.     move.l    #0,a0
  862.     rts
  863.  
  864. findend:
  865.     cmp.b    #'"',(a0)
  866.     beq    findend_quote
  867.  
  868. findend_space:
  869.     addq.l    #1,a0
  870.     cmp.b    #" ",(a0)
  871.     beq    findend_space1
  872.     cmp.b    #0,(a0)
  873.     beq    findend_space1
  874.     cmp.l    commandend,a0
  875.     bls    findend_space
  876.     move.l    #0,a0
  877.     rts
  878.  
  879. findend_space1:
  880.     subq.l    #1,a0
  881.     rts
  882.  
  883. findend_quote:
  884.     addq.l    #1,a0
  885.     cmp.b    #'"',(a0)
  886.     bne    findend_quote1
  887.     rts
  888.  
  889. findend_quote1:
  890.     cmp.l    commandend,a0
  891.     bls    findend_quote
  892.     move.l    #0,a0
  893.     rts
  894.  
  895.     include    "src:Num2ASCII-2.S"
  896.     include    "src:Percentage.S"
  897.  
  898. **********
  899. ** DATA **
  900. **********
  901.  
  902.     section    fastdata,data
  903.  
  904. spacepointer:
  905.     dc.l    spacebuf
  906.  
  907. text_helptext:
  908.     incbin    "src:Port/PortOpts1"
  909.  
  910. text_credits:
  911.     incbin    "src:Port/PortOpts2"
  912.  
  913. text_cursoroff:
  914.     dc.b    27,"[0 p"
  915.  
  916. text_cursoron:
  917.     dc.b    27,"[1 p"
  918.  
  919. text_badcomline:
  920.     dc.b    "ERROR!  Bad commandline.",10
  921.  
  922. text_nomemory:
  923.     dc.b    "ERROR!  Not enough memory.",10
  924.  
  925. text_badsource:
  926.     dc.b    "ERROR!  Bad sourcefile.",10
  927.  
  928. text_nosource:
  929.     dc.b    "ERROR!  Could not open source file.",10
  930.  
  931. text_nodest:
  932.     dc.b    "ERROR!  Could not open destination file.",10
  933.  
  934. text_badmode:
  935.     dc.b    "ERROR!  Bad mode specification.",10
  936.  
  937. text_nocomlinespace:
  938.     dc.b    "ERROR!  The mode must be separated with at least one space.",10
  939.  
  940. text_input:
  941.     dc.b    27,"[1mInput: ",27,"[0m"
  942.  
  943. text_output:
  944.     dc.b    "  ",27,"[1mOutput: ",27,"[0m"
  945.  
  946. dosname:
  947.     dc.b    "dos.library",0
  948.  
  949. text_amigasuf:
  950.     dc.b    ".AMI"
  951.  
  952. text_pcsuf:
  953.     dc.b    ".PC"
  954.  
  955. text_sf7suf:
  956.     dc.b    ".SF7"
  957.  
  958. text_cr:
  959.     dc.b    13
  960.  
  961. text_lf:
  962.     dc.b    10
  963.  
  964. text_final:
  965.     dc.b    27,"[1mFile size change:",27,"[0m "
  966.  
  967. text_negsign:
  968.     dc.b    "-"
  969.  
  970. text_possign:
  971.     dc.b    "+"
  972.  
  973. text_percentsign:
  974.     dc.b    "%        "
  975.  
  976. text_doublespace:
  977.     dc.b    "  "
  978.  
  979. mode_cutspace:
  980.     dc.b    1
  981.  
  982.     if    testmode=1
  983.  
  984. test_comline:
  985.     dc.b    "-n -t8 l ram:test1",10
  986.  
  987. test_comlineend:
  988.  
  989. test_len    =    test_comlineend-test_comline
  990.     endc
  991.  
  992.     section    fastblank,bss
  993.  
  994. writtenbytes:
  995.     ds.l    1
  996.  
  997. readbytes:
  998.     ds.l    1
  999.  
  1000. sourcehandle:
  1001.     ds.l    1
  1002.  
  1003. desthandle:
  1004.     ds.l    1
  1005.  
  1006. outstruct:
  1007.     ds.l    1
  1008.  
  1009. destnamestart:
  1010.     ds.l    1
  1011.  
  1012. destnameend:
  1013.     ds.l    1
  1014.  
  1015. destnamelen:
  1016.     ds.l    1
  1017.  
  1018. sourcenamestart:
  1019.     ds.l    1
  1020.  
  1021. sourcenameend:
  1022.     ds.l    1
  1023.  
  1024. sourcenamelen:
  1025.     ds.l    1
  1026.  
  1027. commandstart:
  1028.     ds.l    1
  1029.  
  1030. commandend:
  1031.     ds.l    1
  1032.  
  1033. commandlen:
  1034.     ds.l    1
  1035.  
  1036. dosbase:
  1037.     ds.l    1
  1038.  
  1039. spacenumber:
  1040.     ds.l    1
  1041.  
  1042. col:
  1043.     ds.w    1
  1044.  
  1045. mode:
  1046.     ds.b    1
  1047.  
  1048. sourcename:
  1049.     ds.b    256
  1050.  
  1051. destname:
  1052.     ds.b    256
  1053.  
  1054. sourcebuf:
  1055.     ds.b    1024
  1056.  
  1057. destbuf:
  1058.     ds.b    2048
  1059.  
  1060. spacebuf:
  1061.     ds.b    1024
  1062.  
  1063. numberbuf:
  1064.     ds.b    10
  1065.  
  1066. tabsize:
  1067.     ds.b    1
  1068.  
  1069. mode_case:
  1070.     ds.b    1
  1071.  
  1072. len_helptext    =    text_credits-text_helptext
  1073. len_credits    =    text_cursoroff-text_credits
  1074.